﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="BizParamSetting_Import.aspx.vb" Inherits="PubProject.BizParamSetting_Import" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>跨公司参数引入</title>
    <script language="javascript" src="/_controls/settings.aspx"></script>
		<LINK href="/_grid/grid.css" type="text/css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/dialogs.css">
		<link rel="stylesheet" type="text/css" href="/_nav/taskbox.css">
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script language="javascript" src="/PubProject/js/Public.js"></script>
	<script>
        var Try = {
          these : function() {
            var returnValue;

            for(var i=0; i<arguments.length; i++) {
              var lambda = arguments[i];
              try {
                returnValue = lambda();
                break;
              } catch(e) {}
            }
            return returnValue;
          }
        };

        //创建XMLHTTPRequest对象
        var xmlhttp = Try.these(
          function() {return new ActiveXObject('Msxml2.XMLHTTP')},
          function() {return new ActiveXObject('Microsoft.XMLHTTP')},
          function() {return new XMLHttpRequest()}
        ) || false;
        
	    function onImportClick()
	    {
	        if(document.getElementById("txtBUGUID").value=="")
	        {
	            alert("请选择一个公司");
	            return false;
	        }
	        var param = document.getElementById("__param").value;
            var BUGUID=document.getElementById("txtBUGUID").value;
	        if(param == "cb_FKSPType")
	        {
	            var url="/PubProject/BizParam/Cbgl/chkFKSPType.aspx?BUGUID="+BUGUID;
	            xmlhttp.open('get',url,false);
	            xmlhttp.send(null);
	            var returnText=xmlhttp.responseText;
	            if(returnText=="1")
	            {
	                alert("该公司下没有子级付款类型，不允许引入！");
	                return;
	            }
	        }
	        var url="chkForImport.aspx";
	        var tb="";
	        var msg="";
	        var flag=0;
	        switch(param)
	        {
	            case "cb_TaxSetting":
	                tb="cb_Tax";
	                msg="该公司下没有税目，不允许引入！"
	                break;
                case "cb_FinanceJsParam":
	                tb="myBizParamOption";
	                msg="该公司下没有结算方式，不允许引入"
	                flag=1;
	                break;
                case "cb_ProductProject":
	                tb="cb_ProductProject";
	                msg="该公司下没有标段，不允许引入！"
	                break;
                case "cb_Bank":
	                tb="myBizParamOption";
	                msg="该公司下没有付款银行，不允许引入！"
	                flag=1;
	                break;
                case "cb_FundParam":
	                tb="myBizParamOption";
	                msg="该公司下没有子级款项类型，不允许引入！"
	                flag=1;
	                break;
                default:
	                break;
	        }
	        
	        if(tb!="" && msg!="")
	        {
	            url+="?tb="+tb+"&BUGUID="+BUGUID+"&flag="+flag+"&param="+param;
	            xmlhttp.open('get',url,false);
	            xmlhttp.send(null);
	            var returnText=xmlhttp.responseText;
	            if(returnText=="1")
	            {
	                alert(msg);
	                return;
	            }
	        }

	        if(!window.confirm('将清空列表现有数据，是否引入！'))
	            return false;
	        openWaiting();
	        
	        
	        var sFile = "/PubProject/BizParam/BizParam_XMLHTTP.aspx?";
			sFile += "param="+escape(__param.value);   //参数名称
			sFile += "&app="+escape(__app.value);    //系统名称
			sFile += "&buguid="+escape(document.getElementById("txtBUGUID").value);  //公司GUID
			
			var sRtn = openXMLHTTP(sFile,"ImportFromCompany");
			if(sRtn == "OK")
			{
				closeWaiting();
				window.opener.location.href = window.opener.location.href;
				window.close();
			}
			else
			{
				alert("操作失败,请关闭重试！");
				document.getElementById("btnImport").disabled=true;
				return false;
			}
	    }
	    function getPageByParam(param)//根据参数选择展示页面
	    {
	        switch(param)
	        {
	            //非标准参数:
	            case "cb_FKSPType":
	            case "cb_ProductProject":   //成本标段设置
	            case "cb_TaxSetting": //成本税目设置
	                return "BizParamSetting_Import_Special.aspx";
	            //标准参数:    
	            default:        
	                return "BizParamSetting_Import_Right.aspx";
	        }
	        
	    }
	    function onBUChange(buguid)//处理公司改变事件，刷新展示页面
	    {
	        var param = document.getElementById("__param").value
	        document.getElementById("txtBUGUID").value = buguid;//记录公司GUID
	        
	        var sPath = getPageByParam(param);
	        sPath+="?param=" + escape(param);
	        sPath+="&funcid=" + escape(document.getElementById("__funcid").value);
	        sPath+="&buguid=" + escape(buguid);

	        window.frames["appIframe_right"].location.href = sPath;//刷新展示页面
	    }
	</script>
</head>
<body>
    <table style="width:100%;height:100%" cellspacing="0" cellpadding="0">
	<tr>
	    <td class="main">
	        <table style="width:100%;height:100%" cellspacing="0" cellpadding="0">
	            <tr>
	                <td style="height:100%; width:150px">
			            <iframe id="appIframe" src="BizParamSetting_Import_Left.aspx?funcid=<%= Request.QueryString("funcid")%>&param=<%=Request.QueryString("param") %>" width="100%" height="100%" frameborder="0" scrolling="no"></iframe>
		            </td>
		            <td style=" width:10px">&nbsp;</td>
		            <td>
			            <iframe id="appIframe_right" width="100%" height="100%" frameborder="0" scrolling="no"></iframe>
		            </td>
	            </tr>
	        </table>
	    </td>
	</tr>
	<tr style="height:40px">
		<td class="buttons">
		    <form runat="server" id="form1">
		    <asp:HiddenField runat="server" ID="txtParam" />
		    <asp:HiddenField runat="server" ID="txtBUGUID" />
		    <input type="button" id="btnImport" runat="server" value="引 入" onclick="onImportClick();"/>&nbsp;&nbsp;
		    <input type="button" value="取 消" onclick="window.close();" /></form>
		</td>
	</tr>
    </table>
</body>
</html>